﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using JeanFish.Tracing;
using System.Diagnostics;

namespace JeanFish.UnitTest.Tracing
{
    [TestClass]
    public class TracingTest
    {
        [TestMethod]
        public void LogTest()
        {
            TextWriterTraceListener text = new TextWriterTraceListener(@"D:\testlog.txt");
            text.TraceOutputOptions |= TraceOptions.ProcessId | TraceOptions.ThreadId | TraceOptions.Callstack | TraceOptions.DateTime;
            EventLogTraceListener eventLog = new EventLogTraceListener("test");
            eventLog.TraceOutputOptions |= TraceOptions.ProcessId | TraceOptions.ThreadId | TraceOptions.Callstack | TraceOptions.DateTime;
            Log.Source.Switch = new SourceSwitch("switch")
            {
                Level=SourceLevels.All
            };
            Log.Source.Listeners.Add(text);
            Log.Source.Listeners.Add(eventLog);
            Log.Write(TraceEventType.Information,1);
            Log.Write(TraceEventType.Information, 2, new { Name = "test object" });
            Log.Write(TraceEventType.Information, 9, new { Name = "test object" }, new { Name = "test object" });
            Log.Write(TraceEventType.Information, 3, "test message");
            Log.Write(TraceEventType.Information,4, "test formated message {0}", "test");
            Log.Write();
            Log.Information("test information");
            Log.Information("test formated information {0}", "test");
            new Exception("test log exception").WriteLog(8);
            Log.Write();
            Assert.IsTrue(true);
        }
    }
}
